package com.google.code.expr.lang;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;


public class EXPRConditional extends EXPRCommand {

	private ArrayList<EXPRConditionalCase> mCases;
	
	public EXPRConditional() {
		mCases = new ArrayList<EXPRConditionalCase>();
	}

	public void addCase(EXPRConditionalCase c) {
		mCases.add(c);
	}
	
	public ArrayList<EXPRConditionalCase> getCases() {
		return mCases;
	}

	public String toString() {
		return toString("");
	}
	
	public String toString(String pIndent) {
		StringWriter writer = new StringWriter();
		PrintWriter out = new PrintWriter(writer);
		for (EXPRConditionalCase c : mCases) {
			out.println(c.toString(pIndent));
		}
		out.print(pIndent);
		out.print(COMMAND_START);
		out.print(EXPRConditonalType.ENDIF);
		out.print(COMMAND_END);
		return writer.toString();
	}
}
